package com.tencent.sr.iris.basic.saas.restapi.poster;


import com.alibaba.fastjson.JSON;
import com.tencent.sr.iris.basic.saas.service.poster.InvitePosterService;
import com.tencent.sr.iris.basic.service.interfaces.request.poster.AddOrUpdateInvitePosterRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.poster.InvitePosterCommonRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.poster.InvitePosterMoveRequest;
import com.tencent.sr.iris.basic.service.interfaces.response.poster.InvitePosterDetailResponse;
import com.tencent.sr.iris.basic.service.interfaces.response.poster.InvitePosterListResponse;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import com.tencent.sr.rmall.springbootstarter.authtoken.localbean.AppUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import javax.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api("邀请海报相关接口")
@RequestMapping("/iris/basic/saas/v1/invitePoster")
public class InvitePosterController {

    @Resource
    private InvitePosterService invitePosterService;

    @Resource
    private AppUser appUser;

    @ApiOperation("新增场景")
    @PostMapping("/save")
    HttpResult<Boolean> save(@Valid @RequestBody AddOrUpdateInvitePosterRequest request) {
        log.info("invitePoster save request:{}", JSON.toJSONString(request));
        request.setOperateId(appUser.getUid());
        return invitePosterService.save(request);
    }

    @ApiOperation("编辑场景")
    @PostMapping("/update")
    HttpResult<Boolean> update(@Valid @RequestBody AddOrUpdateInvitePosterRequest request) {
        log.info("invitePoster update request:{}", JSON.toJSONString(request));
        request.setOperateId(appUser.getUid());
        return invitePosterService.update(request);
    }

    @ApiOperation("删除场景")
    @PostMapping("/delete")
    HttpResult<Boolean> delete(@Valid @RequestBody InvitePosterCommonRequest request) {
        log.info("invitePoster delete request:{}", JSON.toJSONString(request));
        request.setOperateId(appUser.getUid());
        return invitePosterService.delete(request);
    }

    @ApiOperation("场景详情")
    @PostMapping("/detail")
    HttpResult<InvitePosterDetailResponse> detail(@Valid @RequestBody InvitePosterCommonRequest request) {
        log.info("invitePoster detail request:{}", JSON.toJSONString(request));
        request.setOperateId(appUser.getUid());
        return invitePosterService.detail(request);
    }

    @ApiOperation("场景列表")
    @PostMapping("/list")
    HttpResult<PaginationResponse<InvitePosterListResponse>> list(
            @Valid @RequestBody PaginationRequest<InvitePosterCommonRequest> request) {
        log.info("invitePoster list request:{}", JSON.toJSONString(request));
        return invitePosterService.list(request);
    }

    @ApiOperation("移动场景")
    @PostMapping("/move")
    HttpResult<Boolean> move(@Valid @RequestBody InvitePosterMoveRequest request) {
        log.info("invitePoster move request:{}", JSON.toJSONString(request));
        request.setOperateId(appUser.getUid());
        return invitePosterService.move(request);
    }

}
